#include <QCoreApplication>
#include <iostream>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    char teststring[40]={"This       test       string."};
    int space=0;

    for(int i=0;i<40;i++)
    {
        cout<<teststring[i];
    }
    cout<<endl;

    for(int i=0;i<40;i++)
    {
        if(teststring[i]==' ')
        {
        while(teststring[i]==' ')
        {
            i++;
            space++;
        }
        i-=space;
        for(int t=i;t<(40-space);t++)
        {
            teststring[t+1]=teststring[(t+space)];
        }
        space=0;
        }
    }
    for(int i=0;i<40;i++)
    {
        cout<<teststring[i];
    }
    return a.exec();
}
